package com.example.securitydemo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Fausto
 * @Date 2022/9/4 17:27
 * @Comment 代码操作控制层
 * @Version 1.0
 */
@Api(tags = "代码控制器",description = "权限控制测试接口")
@RestController
@RequestMapping("code")
public class CodeController {

    /**
     * 拉代码
     * @return
     */
    @ApiOperation("拉代码")
    @GetMapping("/pull")
    @PreAuthorize("@ex.hasAuthority('dev:code:pull')")
    public String pull() {
        return "pull code success!";
    }

    /**
     * 合代码
     * @return
     */
    @ApiOperation("合代码")
    @GetMapping("/merge")
    @PreAuthorize("@ex.hasAuthority('dev:code:merge')")
    public String merge() {
        return "merge code success!";
    }
}
